﻿using HomeWork911.Api.Write.Appliaction.Commond;
using HomeWork911.Api.Write.Dto;
using HomeWork911.ErrorCode;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace HomeWork911.Api.Write.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class QueryController : ControllerBase
    {
        IMediator mediator;
        ILogger<ManualResetEvent> logger;

        public QueryController(IMediator mediator, ILogger<ManualResetEvent> logger)
        {
            this.mediator = mediator;
            this.logger = logger;
        }
        /// <summary>
        /// 添加权限
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回增加请求</returns>
        [HttpPost]
        public async Task<ApiResult<int>> PermissionAdd(AddPermisionCommond request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 更改数据
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<ApiResult<PermissionDto>> UpdatePermission(UpdatePermission request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 增加用户角色信息
        /// </summary>
        /// <param name="request">请求</param>
        /// <returns>返回增加信息</returns>
        [HttpPost]
        public async Task<ApiResult<int>> UserAdd(UserAddCommond request)
        {
            return await mediator.Send(request);
        }
    }
}
